package com.dongdongshop.service.imp;

import com.alibaba.dubbo.config.annotation.Service;
import com.dongdongshop.mapper.TbSellerMapper;
import com.dongdongshop.pojo.TbSeller;
import com.dongdongshop.pojo.TbSpecification;
import com.dongdongshop.service.SellerService;
import com.dongdongshop.util.PageBean;

import javax.annotation.Resource;
import java.util.List;

@Service
@org.springframework.stereotype.Service
public class SellerServiceImpl implements SellerService {
    @Resource
    private TbSellerMapper tbSellerMapper;

    @Override
    public Integer addinfo(TbSeller s) {
        return tbSellerMapper.insertSelective(s);
    }

    @Override
    public TbSeller getByName(String username) {
        return tbSellerMapper.selectByPrimaryKey(username);
    }

    @Override
    public PageBean<TbSeller> getinfo(TbSeller t, Integer number, Integer pageSize) {
        PageBean<TbSeller> b = new PageBean<>();
        b.setPageNum(number);
        b.setPageSize(pageSize);
        List<TbSeller> list = tbSellerMapper.getinfo(b,t);
        List<TbSeller> slist = tbSellerMapper.getByName(t);
        b.setResult(list);
        b.setTotal(slist.size());
        return b;
    }

    @Override
    public TbSeller toDetail(String sellerId) {
        return tbSellerMapper.selectByPrimaryKey(sellerId);
    }

    @Override
    public Integer toStatus(TbSeller tbSeller) {
        return tbSellerMapper.updateByPrimaryKeySelective(tbSeller);
    }
}
